Crate skip_error[][src]

Expand description

This crate provides a single macro to help skipping a error in a loop, possibly logging it.

For example, imagine you have some code like this.

for string_number in &["1", "2", "three", "4"] {
  let number: u32 = match string_number.parse() {
    Ok(n) => n,
    Err(e) => continue,
  };
}

Then you can use the macro skip_error! to write like this.

for string_number in &["1", "2", "three", "4"] {
  let number: u32 = skip_error!(string_number.parse());
}

If you want the error to be logged, you can use the feature log. The logging will be done in WARN level with the standard logging interface provided by log.

Macros

skip_error

skip_error returns the value of a Result or continues a loop.

skip_error_and_log

skip_error_and_log returns the value of a Result or log and continues a loop.

Structs

SkipErrorIter

An iterator that ignore errors

Traits

SkipError

Trait to extend any Iterator where the Iterator::Item is a Result. This allows to skip errors and keep only the Ok() values.